<template>
  <V-CommonHeaderLeft>
    <div class="purchasing-reconciliation">
      <Navigation :msg="navMsg"></Navigation>
      <div class="purchasing-table"
           :style="{height: tableHeight}">
        <div class="datum">
          <ul>
            <li>
              <p>应付欠款</p>
              <p>
                <span class="num">￥4,540.00</span>
              </p>
            </li>
            <li>
              <p>付款待审核</p>
              <p>
                <span class="num">￥52,580.00</span>
              </p>
            </li>
            <li>
              <p>应收欠款</p>
              <p>
                <span class="num">￥52,580.00</span>
              </p>
            </li>
            <li>
              <p>收款待审核</p>
              <p>
                <span class="num">￥52,580.00</span>
              </p>
            </li>
          </ul>
        </div>
        <el-table ref="multipleTable"
                  :data="stock"
                  style="width: 100%;"
                  class="table-class">
          <el-table-column type="index"
                           min-width="5%"
                           label="序号">
          </el-table-column>
          <el-table-column prop="outWarehouse"
                           min-width="16.6%"
                           label="供应商名称">
            <template slot-scope="scope">
              <span :title="scope.row.outWarehouse">{{ scope.row.outWarehouse }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="outWarehouse"
                           label="应付欠款"
                           min-width="18.3%"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.outWarehouse">{{ scope.row.outWarehouse }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderPerson"
                           label="付款待审核"
                           min-width="20.8%"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.orderPerson">{{ scope.row.orderPerson }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderPerson"
                           min-width="18.3%"
                           label="应收欠款"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.remarks">{{ scope.row.remarks }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="submitTime"
                           min-width="20.8%"
                           label="收款待审核"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.q"></span>
              <div class="hover-box">
                <router-link to="#">查看详细</router-link>
                <router-link to="#">批量付款</router-link>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <Paging :msg="pageMsg.length"
              ref="fn"
              @pageNum="getPageNum"
              @pageId="getPageId"></Paging>
    </div>
  </V-CommonHeaderLeft>
</template>
<script>
import VCommonHeaderLeft from '@/components/common/vCommonHeaderLeft/VCommonHeaderLeft'
import Navigation from '@/components/common/navigation/Navigation'
import Paging from '@/components/common/paging/Paging'
export default {
  data () {
    return {
      tableHeight: '',
      pageNum: 15, // 每页默认显示15条,
      pageId: 1, // 页面id
      judgeStatus: false, // 排序状态
      navMsg: [
        {
          name: '采购',
          path: '/purchasingOrder'
        },
        {
          name: '供应商对账',
          path: ''
        }
      ],
      stock: [],
      pageMsg: [
        {
          orderId: 'CK-20190412-0003',
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: '',
          cash: 10
        },
        {
          orderId: 'CK-20190423-0043'
        },
        {
          orderId: 'CK-20100422-023',
          from: {
            type: '供应商',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '待发货',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-22',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          orderId: 'CK-20200422-0563',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          auditTime: '2019-04-21',
          submitTime: '2019-04-23',
          eemarks: ''
        }
      ]
    }
  },
  components: {
    Navigation,
    Paging,
    VCommonHeaderLeft
  },
  created () {
    this.stock = this.pageMsg
    this.getHight()
    window.addEventListener('resize', this.getHight)
  },
  destroyed () {
    window.removeEventListener('resize', this.getHight)
  },
  methods: {
    getHight () {
      this.tableHeight = window.innerHeight - 160 + 'px'
    },
    getPageId (id = 1) {
      this.pageId = id
      this.stock = this.$refs.fn.sliceArray(this.pageMsg, this.pageNum, id - 1)
    },
    getPageNum (num) {
      this.pageNum = num
      this.getPageId()
    }
  }
}
</script>
<style lang="scss" scoped>
.purchasing-reconciliation {
  width: 100%;
  margin-right: 10px;
  overflow: hidden;
  background-color: #ffffff;
  .purchasing-table {
    width: 100%;
    overflow: scroll;
    overflow-x: hidden;
    overflow-y: hidden;
    &:hover {
      overflow-y: overlay;
    }
    &::-webkit-scrollbar {
      width: 8px;
    }
    &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      background-color: rgba(0, 0, 0, 0.2);
    }
    &::-webkit-scrollbar-track {
      border-radius: 0;
      background-color: rgba(0, 0, 0, 0.1);
    }
    @mixin el-common($el-color, $el-height, $el-class) {
      padding: 0;
      text-align: center;
      color: $el-color;
      height: $el-height;
      line-height: $el-height;
      &:not(:first-child) {
        #{$el-class} {
          width: 100%;
          line-height: 20px;
          display: -webkit-box;
          overflow: hidden;
          white-space: normal !important;
          text-overflow: ellipsis;
          word-wrap: break-word;
          word-break: break-all;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }
    }
    /deep/ .table-class {
      font-size: 12px;
      padding: 0;
      overflow: hidden;
      .el-table--scrollable-x .el-table__body-wrapper {
        overflow-x: hidden;
      }
      tr {
        height: 40px;
        position: relative;
        &:hover {
          .hover-box {
            display: flex;
          }
        }
        td {
          @include el-common(
            $el-color: #333,
            $el-height: 40px,
            $el-class: "span"
          );
          &:first-child {
            &:hover {
              cursor: pointer;
              color: #20bdeb;
            }
          }
          .hover-box {
            display: none;
            position: absolute;
            top: 0;
            right: 0;
            height: 100%;
            border: 0 none;
            background-color: #a3bbd4;
            box-shadow: none;
            align-items: center;
            text-align: center;
            cursor: pointer;
            white-space: normal;
            word-break: normal;
            padding: 0 12px;
            z-index: 2;
            a {
              display: flex;
              width: 60px;
              padding: 0 12px;
              color: #ffffff;
              height: 100%;
              justify-content: center;
              align-items: center;
              font-size: 12px;
            }
          }
        }
        th {
          @include el-common(
            $el-color: #666,
            $el-height: 50px,
            $el-class: ".cell"
          );
          font-weight: normal;
          background-color: #fcfcfc;
        }
      }
      .order-from {
        color: #65d142;
      }
      .not-status {
        color: #ff3838;
      }
    }
    .datum {
      ul {
        display: flex;
        border: {
          top: 1px solid #e3e3e3;
          bottom: 1px solid #e3e3e3;
        }
        li {
          flex: 1;
          height: 100px;
          text-align: center;
          line-height: 50px;
          border-right: 1px solid #e3e3e3;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          p {
            font-size: 12px;
            color: #666;
            line-height: 2;
            .num {
              font-size: 18px;
              line-height: 2;
              font-weight: 600;
              margin-right: 2px;
            }
          }
        }
      }
    }
  }
}
</style>
